Skip to content

[share_plus] Migrate Android part to Kotlin#666

Merged
vbuberen merged 11 commits intofluttercommunity:mainfrom
vbuberen:refactor/share_plus_android
Feb 20, 2022
Merged

[share_plus] Migrate Android part to Kotlin#666
vbuberen merged 11 commits intofluttercommunity:mainfrom
vbuberen:refactor/share_plus_android

Conversation

@vbuberen
Copy link
Copy Markdown
Collaborator

Description

This is first of PRs to migrate Android parts of Plus plugins to Kotlin in order to modernise the code, provider better null-safety handling and, potentially, helping engage more contributors with Kotlin experience.

The migration is done manually, not via Java to Kotlin converter to avoid possible potential issues. I tried to not change the behavior as much as I could (however, in some places I added some additional checks) while using all the Kotlin possibilities. Everything works in a same way as it worked before, but the code is much more concise.

With this PR we are getting to the point where we would not need google-java-format anymore. I suggest to replace it with a combination of KtLint + Detekt, which I would add in a separate PR.

Did a minor version change, since there were no breaking changes.

I plan to do the same migrations for the other plugins we have in Plus plugins.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

when (call.method) {
"share" -> {
expectMapArguments(call)
// Android does not support showing the share sheet at a particular point on screen.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to preserve all the original code comments

putExtra(Intent.EXTRA_SUBJECT, subject)
}

val chooserIntent = Intent.createChooser(shareIntent, null /* dialog title optional */)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to preserve all the original code comments.
I believe at a later point we could provide additional parameter to let users set the title for this chooser.


override fun onAttachedToEngine(binding: FlutterPluginBinding) {
methodChannel = MethodChannel(binding.binaryMessenger, CHANNEL)
share = Share(context = binding.applicationContext, activity = null)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly specified names of parameters for better readability on Github

@vbuberen
Copy link
Copy Markdown
Collaborator Author

The failing pub.dev check is due to #655 and failing tests are caused by a flaky test in package_info_plus (it runs successfully on my local machine 🤔 )

@vbuberen vbuberen requested a review from miquelbeltran January 8, 2022 18:48
@vbuberen vbuberen added android share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin labels Jan 15, 2022
Copy link
Copy Markdown
Member

@miquelbeltran miquelbeltran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! sorry for the late review

@vbuberen
Copy link
Copy Markdown
Collaborator Author

Thanks. Will make a few updates, since it is quite a lot of time passed and there are newer versions of Gradle, etc. available.

@vbuberen vbuberen merged commit eca0f0b into fluttercommunity:main Feb 20, 2022
@vbuberen vbuberen deleted the refactor/share_plus_android branch February 20, 2022 14:22
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

android share_plus Feature, Enhancement, Bug Fixes for Share Plus Plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants